<?php

namespace app\admin\model;

use think\Model;

class alogs extends Model
{
    public static $type = [
        'system' => 0, //系统日志
        'user' => 1, //用户日志
        'node' => 2, //节点操作日志
    ];

    public static function alogsAdd($adid, $type, $describe)
    {
        if (!in_array($type, self::$type)) throw new \Exception('非法日志类型');

        $log = [
            'adid' => $adid,
            'type' => $type,
            'describe' => $describe,
            'create_time' => time(),
            'addlogip' => get_client_ip(),
        ];
        $result = self::insert($log);
        if (!$result) throw new \Exception('添加日志失败');
    }
}